#pragma once

#include "../Common/Common.h"
#include "../Thread/PosixThreads.h"

#include "EventType.h"


enum HandlerPriority
{
	PRIORITY_1 = 1,
	PRIORITY_2,
	PRIORITY_3,
	PRIORITY_4,
	PRIORITY_5,	
};

class PSDF_CORE_DLL_DECL EventHandler
{
public:
	EventHandler() : _priority( PRIORITY_3 ) {}

	EventHandler( HandlerPriority pr ) : _priority( pr ) {}

	EventHandler( const EventHandler& handler ) { _priority = handler._priority; _handlerMutex = handler._handlerMutex; }

	virtual ~EventHandler() {}

public:
	void					setPriority( HandlerPriority pr ) { _priority = pr; }

	HandlerPriority			getPriority() { return _priority; }

	void					handle( unsigned eventType, int param1, int param2 );
	
	virtual string			getModuleName() = 0;

protected:	
	virtual void			handleSystemEvent( unsigned eventType, int param1, int param2 );
	
	virtual void			handleCustomEvent( unsigned eventType, int param1, int param2 );

protected:	
	HandlerPriority			_priority;

	PosixMutex				_handlerMutex;
};